<?php

require_once 'common.php';
log_action("In Page : ".__FILE__);

if(!isset($_SESSION)){session_start();}

//get the q parameter from URL
$loginname=$_GET["name"];
$password = $_GET["pwd"];
$savecookie = $_GET["savecookie"];

$response = "Login failed";

$query = "select id from user where loginname='$loginname' and `password` = '$password' ;";
$result = executeScalar($query);

if($result > 0 )
{
	$response = "Login succeed";
	$_SESSION['uid'] = $result;
	
	if($savecookie=="true")
	{
		SaveCookieUID($result);
	}
}
else
{
	unset($_SESSION['uid']);
}

//return value
echo $response;

?>